-----------------------------------
-- Area: Temple of Uggalepih
-- NPC:  Stone Picture Frame
-- Opens door to Den of Rancor using Painbrush of Souls
-- @pos  159
-----------------------------------
package.loaded["scripts/zones/Temple_of_Uggalepih/TextIDs"] = nil;
-----------------------------------

require("scripts/globals/keyitems");
require("scripts/zones/Temple_of_Uggalepih/TextIDs");

-----------------------------------
-- onTrade Action
-----------------------------------

function onTrade(player,npc,trade)
end; 

-----------------------------------
-- onTrigger Action
-----------------------------------

function onTrigger(player,npc)
		player:messageSpecial(PAINTBRUSH_OFFSET + 22); 
		player:setPos(-46.013,0,20.472,153);
end; 

-----------------------------------
-- onEventUpdate
-----------------------------------

function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;

-----------------------------------
-- onEventFinish
-----------------------------------

function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
	
	if(csid == 0x0032) then
		-- Soon !
	elseif(csid == 0x003C) then
		time_elapsed = os.time() - player:getVar("started_painting");
		if(time_elapsed >= 30) then
			player:messageSpecial(PAINTBRUSH_OFFSET + 22); -- You succeeded in projecting the image in your soul to the blank canvas. The door to the Rancor Den has opened!<Prompt>
			GetNPCByID(17428965):openDoor(40); -- Open the door to Den of Rancor for 40 sec
		else
			player:messageSpecial(PAINTBRUSH_OFFSET + 21); -- You were unable to fill the canvas with an image from your soul.
		end
		player:setVar("started_painting",0);
	end
	
end;